package com.uchengwang.ui.cm_ui.ucity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uchengwang.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by U城网 on 2017/11/28.
 */

public class ChooseItemReasonAdapter extends BaseAdapter{
    private Context context;
    private List<String> list = new ArrayList<>();

    public ChooseItemReasonAdapter(Context context, List<String> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        VH vh = null;
        if (view == null){
            vh = new VH();
            view = LayoutInflater.from(context).inflate(R.layout.item_view_text, null, false);
            vh.tv = (TextView) view.findViewById(R.id.tv);

            view.setTag(vh);
            AutoUtils.autoSize(view);
        }else {
            vh = (VH) view.getTag();
        }

        vh.tv.setText(list.get(i));
        return view;
    }

    private class VH{
        private TextView tv;
    }
}
